1. Field of the Invention
The present invention relates generally to a three-dimensional graphic processing apparatus for performing shading on a three-dimensional figure expressed by a plurality of polygons, and in particularly to a three-dimensional graphic processing apparatus having means for correcting a quantization error caused by rounding real values into integer values for display.
2. Description of the Related Art
In the field of conventional three-dimensional graphic processing, a Gouraud shading method is most common as an algorithm for carrying out three-dimensional display with shading. In the Gouraud shading method, a there-dimensional figure to be described is expressed by a polygon (e.g. a very small triangle). The values of three-dimensional coordinates and luminance of all points within the polygon are obtained by linear interpolation on the basis of data relating to the three-dimensional coordinates and luminance at the apices of the polygon. Thus, the figure is provided with smooth shading.
The Gouraud shading is described in detail in the following documents:
1) "COMPUTER GRAPHICS", J. D. Foley, A. Vandam, translated by Imamiya, Japan Computer Association, P. P. 587-596,
2) NIKKEI ELECTRONICS, 1986, vol. 4.7 (No. 392), P. P. 171-194, and
3) Japanese Patent Application No. 61-227980 (a senior application by the same applicant as the present application).
The Gouraud shading will now be described in brief.
Suppose that the polygon is a small triangle as shown in FIG. 1. The values in the three-dimensional coordinates (X-axis, Y-axis, Z-axis) and the value of luminance I at the apices of the triangle are represented by A (X1, Y1, Z1, I1), B (X2, Y2, Z2, I2), C (X3, Y3, Z3, I3). First, the inclination of the values X1, Z1 and I1 on the left side AB and the inclination of the value X2 on the right side AC are obtained.
The inclination .DELTA.X1 of value X1, the inclination .DELTA.Z1 of value Z1, the inclination .DELTA.I1 of value I1 and the inclination .DELTA.X2 of value X2 are given by the following equations: ##EQU1##
Since the figure is a triangle, the inclination .DELTA.Ia of value I and the inclination .DELTA.Za of value Z on a horizontal line (parallel to the Y-axis) have constant values, and are given by ##EQU2##
The inclinations .DELTA.X1, .DELTA.Z1 and .DELTA.I1 on the left side AB are added to the X-axis coordinate X2, Y-axis coordinate Y2, and Z-axis coordinate Z2 at the apex B, thereby finding the coordinates values (Xs, Zs and Is) at the horizontal scan start point. Then, the inclination .DELTA.X2 on the right side AC is added to the X-axis coordinate X2 of the apex B, thereby obtaining the coordinate value Xe at the horizontal scan end point. The inclinations .DELTA.Ia and .DELTA.Za on the horizontal line are added to Is and Zs over the line from Xs to Xe, thus finding values I and Z at each point.
In this manner, the figure is entirely scanned horizontally. All arithmetic operations for the scan are performed in the three-dimensional graphic processing apparatus on the basis of real numbers with a given precision (e.g. double precision). Thus, the coordinates values Xs, Zs and Is on the left side, the coordinate value Xe on the right side, and the inclinations are all represented by real numbers.
Although the arithmetic operations are performed in the three-dimensional graphic processing apparatus on the basis of real values, a final three-dimensional figure is obtained by quantizing and rounding the real values to integer values at an integer-number of lattice points (pixel points) on the display screen of a display (normally, a raster display). Accordingly, as is shown in FIG. 2, a displacement (round-off error) .DELTA.x occurs between a real point and a lattice point for shading. Thus, the luminance I and depth Z at each point for shading have round-off errors .DELTA.x.multidot..DELTA.Ia and .DELTA.x.multidot..DELTA.Za.
When the X-coordinate value Xs at the start point on the left side of the triangle is obtained, 0.5 is added to the initial value (e.g. X2 at point B) for rounding. Finally, a decimal fraction of the initial value is omitted and the value is rounded to an integer value. Then, as is shown in FIG. 3, the real edge of the figure and the internally calculated edge point for rounding are parallel with an error of 0.5. In this case, .DELTA.x&lt;0.5. If the values .DELTA.Ia and .DELTA.Za are very large, the error of each point increases. In the boundary of two figures, a single point may have different calculated values, and the boundary may be displayed in a zigzag fashion.
As has been described above, in the conventional three-dimensional graphic processing apparatus, the arithmetic operations are performed on the basis of real numbers, but the real numbers are rounded for the shading process. Thus, a displacement appears between the real edge of a figure and the point for shading, and an error occurs in calculation results relating to the boundary of two figures. As a result, the boundary is displayed discontinuously.